<template>
  <div class="vehicle-container"  @click="vehicleTap('close')">
    <div class="vehicle-panel">
      <div class="vehicle-topbar">
        <div @click.stop="vehicleTap('close')">关闭</div>
      </div>
      <!--省份简写键盘-->
      <div v-if="boardType==0">
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyVehicle1"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyVehicle2"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyVehicle3"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row-last">
          <div
            class="vehicle-panel-row-button vehicle-panel-row-button-last"
            v-for="(item, index) in keyVehicle4"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
      </div>
      <!--英文键盘  -->
      <div v-else>
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyNumber"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyEnInput1"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row">
          <div
            class="vehicle-panel-row-button"
            v-for="(item, index) in keyEnInput2"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
        </div>
        <div class="vehicle-panel-row-last">
          <div
            class="vehicle-panel-row-button vehicle-panel-row-button-last"
            v-for="(item, index) in keyEnInput3"
            :key="index"
            @click.stop="vehicleTap(item)"
          >{{item}}</div>
          <div
            class="vehicle-panel-row-button vehicle-panel-row-button-img"
            @click.stop="vehicleTap('delete')"
          >
            <img :src="ic_delete" class="vehicle-en-button-delete" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {

    boardType: {
      type: Number,
      default: 1
    },
  },

  data() {
    return {
      keyVehicle1: '京沪粤津冀豫云辽黑湘',
      keyVehicle2: '皖鲁新苏浙赣鄂桂甘',
      keyVehicle3: '晋蒙陕吉闽贵渝川',
      keyVehicle4: '青藏琼宁使',
      keyNumber: '1234567890',
      keyEnInput1: '港澳QWERTYUP',
      keyEnInput2: '学ASDFGHJKL',
      keyEnInput3: '警电ZXCVBNM',
      ic_delete: require("../assets/images/ic_delete.png")
    }
  },

  methods: {
    vehicleTap(val) {
      switch (val) {
        case 'delete':
          this.$emit("delete");
          break;
        case 'ok':
          this.$emit("ok");
          break;
        case 'close':
          this.$emit("hideKeyboard");
          break;
        default:
          this.$emit("inputchange", val);
      }

    },

  }
}
</script>

<style scoped>
.vehicle-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background-color: rgb(0, 0, 0, 0.1);
}

.vehicle-topbar {
  background-color: #fafafa;
  display: flex;
  justify-content: flex-end;
  border-top: 0.005rem solid #e8e8e8;
  border-bottom: 0.005rem solid #e8e8e8;
  margin-bottom: 0.09rem;
  font-size: 0.35rem;
  padding: 0.15rem 0.2rem;
}

.vehicle-panel {
  width: 100%;
  position: fixed;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 5.1rem;
  background-color: #f0f0f0;
  padding-bottom: 0.1rem;
}

.vehicle-panel-row {
  display: flex;
  justify-content: center;
  align-items: center;
}

.vehicle-panel-row-last {
  display: flex;
  justify-content: center;
  align-items: center;
}

.vehicle-panel-row-button {
  background-color: #fff;
  margin: 0.05rem;
  padding: 0.05rem;
  width: 0.6rem;
  height: 0.8rem;
  text-align: center;
  line-height: 0.6rem;
  border-radius: 0.12rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.4rem;
  border-bottom: 0.05rem solid #8d9194;
  color: #333;
}

.vehicle-panel-row-button-number {
  background-color: #eee;
}

.vehicle-panel-row-button:active {
  background-color: #8d9194;
}

.vehicle-hover {
  background-color: #ccc;
}

.vehicle-panel-row-button-img {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 0.9rem;
}

.vehicle-en-button-delete {
  width: 0.65rem;
  height: 0.55rem;
}

.vehicle-panel-row-button-last {
  width: 0.6rem;
  height: 0.8rem;
  line-height: 0.6rem;
}

.vehicle-panel-ok {
  background-color: #0f4ba1;
  color: #fff;
  width: 1.5rem;
  height: 0.8rem;
}
</style>